package wwiii;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

@PersistenceCapable(detachable = "true")
public class GameState {
	private final static String INVITING   = "Inviting";
	private final static String GENERATING = "Generating";
	private final static String PLAYING    = "Playing";
	private final static String ENDED      = "Ended";

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key key;
	public Key getKey() { return key; }

	@Persistent
	private String name;
	public String getName() { return name; }

	@Persistent
	private boolean canAddPlayer;
	public boolean canAddPlayer() { return canAddPlayer; }

	@Persistent
	private boolean canAddMap;
	public boolean canAddMap() { return canAddMap; }

	private GameState(String name, boolean canAddPlayer, boolean canAddMap) {
		this.name = name;
		this.canAddPlayer = canAddPlayer;
		this.canAddMap = canAddMap;
	}

	public static GameState getInviting(Game game) {
		return new GameState(INVITING, true, false);
	}
	public static GameState getGenerating(Game game) {
		return new GameState(GENERATING, false, true);
	}
	public static GameState getPlaying(Game game) {
		return new GameState(PLAYING, false, false);
	}
	public static GameState getEnded(Game game) {
		return new GameState(ENDED, false, false);
	}
}
